<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/9/19
  Time: 14:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <h1>Request作用域：【一次请求内有效：转发可取得值，重定向得不到值】
        <hr>
    </h1>
    <%
        //3. 再从当前页面取出数据
        List<String> books = (List<String>) request.getAttribute("books");
        if(books != null) {
            for (String book : books) {
                out.println(book + "<br>");
            }
        }else{
        	out.println("重定向得不到值!");
        }
    %>
    <h1>session作用域：【浏览器cookie中存放sessionId，只要浏览器不关闭，就可以通过sessionid找到你的session】
        <hr>
    </h1>
    <%
        //3. 再从当前页面取出数据
        books = (List<String>) session.getAttribute("books");
        out.println("sessionId:" + session.getId() + "<br>");
        if(books != null) {
            for (String book : books) {
                out.println(book + "<br>");
            }
        }
    %>
    <h1>application作用域：【当前应用程序内有效】
        <hr>
    </h1>
    <%
        //3. 再从当前页面取出数据
        books = (List<String>) application.getAttribute("books");
        if(books != null) {
            for (String book : books) {
                out.println(book + "<br>");
            }
        }
    %>
</body>
</html>
